package com.zxz.news.generaterKey;

import java.util.HashMap;
import java.util.Map;

public class KeyGenerator {
	
	private Map<String,KeyInfo> keyMap=new HashMap<String,KeyInfo>(10);
	private static final int POOL_SIZE=1;
	private static KeyGenerator keygen=new KeyGenerator();

	private KeyGenerator() {
	}
	
	public static KeyGenerator getInstance(){
		return keygen;
	}
	
	public long getNextKey(String keyName,int startId){
		if(keyMap.containsKey(keyName)){
			return keyMap.get(keyName).getNextKey();
		}else{
			KeyInfo keyInfo=new KeyInfo(POOL_SIZE,keyName,startId);
			keyMap.put(keyName, keyInfo);
			return keyInfo.getNextKey();
		}
	}
}